Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve URI.open report #444

Merged
merged 2 commits into from
Apr 29, 2024
Merged

Conversation

bobbrodie
Copy link
Member

Overview

This should help resolve #443 that resulted from CodeQL reporting:

Use of Kernel.open or IO.read or similar sinks with a non-constant value

Approach

I've switched from:

URI.open(content, default_headers.merge(headers), &block)

To:

URI.parse(content).open(default_headers.merge(headers), &block)

This should resolve the following case:

If Kernel.open is given a file name that starts with a | character, it will execute the remaining string as a shell command. If a malicious user can control the file name, they can execute arbitrary code. The same vulnerability applies to IO.read, IO.write, IO.binread, IO.binwrite, IO.foreach, IO.readlines and URI.open.

@bobbrodie bobbrodie self-assigned this Apr 28, 2024
@bobbrodie bobbrodie added this to the v3.0.0 milestone Apr 28, 2024
@bobbrodie
Copy link
Member Author

@marlinpierce if you have a moment in the near future, could you take a peek at this and let me know what you think? Thanks in advance if you're able to.

Copy link
Member Author

@bobbrodie bobbrodie Apr 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the changes here are formatting (I'm working on getting Rubocop implemented but for now am cleaning up small things like spacing)

@marlinpierce
Copy link
Contributor

Those changes look fine to me. The only concern I have is removing stubbing and making the method call. If that is not a problem with potentially making a network call then that is fine with me.

@bobbrodie bobbrodie merged commit 3e1deb0 into sumoheavy:master Apr 29, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use of Kernel.open or IO.read or similar sinks with a non-constant value
3 participants